home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / New System Software Extensions / QuickDraw™ GX 1.1.2 / Programming Stuff / Sample Code / Printing Samples / Extensions… / Backwash ƒ / Backwash.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  5.1 KB  |  145 lines  |  [TEXT/MPS ]

  1. /*________________________________________________________
  2.  
  3.     File: Backwash.h
  4.     
  5.     Header file for a printing extension that adds a
  6.     QuickDraw picture to each page despooled.
  7.  
  8.     Dave Hersey
  9.     Apple Developer Technical Support
  10.  
  11.     11/11/92 - dmh - Created.
  12.      1/28/93 - dmh - Cleaned up for a5 seed CD.
  13.      3/26/93 - dmh - Updated for b1c2 (Translator changes).
  14.      8/24/93 - dmh - Updated for b2.
  15.               - The picture is now rolled into the spool
  16.                file as a resource, and applied to each
  17.                page during despooling.
  18.              - Added a TextEdit compatibility mode which
  19.                strips out the white rectangles drawn by
  20.                apps which use TextEdit to print (like
  21.                TeachText).
  22.              - The "intensity" panel item actually
  23.                functions now.
  24.              - Switched to Exception.h assertion stuff
  25.                for error checking.
  26.      9/09/93 - dmh - AddBackwash now displays progress info.
  27.     12/18/93 - dmh - Updated for b3.
  28.      3/22/94 - dmh - Updated for b4.
  29.  
  30.     (Note: there are labels in the Mark menu.)
  31.  
  32. __________________________________________________________*/
  33.  
  34. #include <Types.h>
  35. #include <Errors.h>
  36. #include <Resources.h>
  37. #include <ToolUtils.h>
  38. #include <graphics routines.h>
  39. #include <graphics libraries.h>
  40. #include <graphics types.h>
  41. #include <graphics toolbox.h>
  42. #include <GXExceptions.h>
  43. #include <Collections.h>
  44. #include <Messages.h>
  45. #include <PrintingManager.h>
  46. #include <PrintingMessages.h>
  47. #include <Packages.h>
  48. #include <String.h>
  49. #include <StandardFile.h>
  50.  
  51. #define kDontAddBackwash        0         /* backwash is turned on.            */
  52. #define kAddBackwash            1         /* backwash is turned off.            */
  53. #define kDefaultIntensity        40         /* default backwash intensity.        */
  54.  
  55. #define kCreator                'SpIT'      /* our creator type.                */
  56. #define kBackwashCollectionType    kCreator /* our collection type.            */
  57.  
  58.  
  59. /*    IDs of our user settings collection item and of the
  60.     spool file resource for our backwash picture.        */
  61.     
  62. #define kBackwashSettingsID        gxPrintingExtensionBaseID
  63. #define r_BackwashPICTID        gxPrintingExtensionBaseID +1
  64.  
  65. #define r_BackwashPanel            6000     /* our panel ID.                    */
  66.  
  67. #define d_Intensity                5         /* intensity of image.                */
  68. #define d_SelectPicture            7         /* "Select picture" button.        */
  69. #define d_FileNameItem            9         /* DITL item for filename to load.    */
  70.  
  71. #define r_BackwashStatus        1000     /* Our 'DLOG', 'DITL', and 'STR#'    */
  72.                                          /*    resources for displaying mssgs.    */
  73.  
  74. #define d_StatusFieldItem        1         /* DITL item for dialog text field.*/
  75.  
  76. #define s_StatusLoadPict        1         /* Indices to different status'    */
  77. #define s_ConvertPict            2         /* messages in our STR# resource.    */
  78. #define s_SetShapeIntensity        3
  79. #define s_SpoolShapeResource    4
  80. #define s_PictureNotLoaded        5
  81.  
  82. #define n_dlogLevel              .25        /* Level to display our dialogs at as a    */
  83.                                         /* percentage of the way down the        */
  84.                                         /* screen.  (See PositionWindow.)        */
  85.  
  86.  
  87. // This is what our collection looks like.  Notice the offsets below
  88. // agree with what we've said in our 'xdtl' resource.  This MUST be
  89. // the case.
  90.  
  91. typedef struct BackwashCollection
  92. {                                    // offset:
  93.     long            intensity;        //   0        brightness %
  94.     unsigned char    addBackwash;    //   4        is user adding a backwash?
  95.     unsigned char    useTextEditMode;//     5        use TextEdit compatibility mode?
  96.                                     //            (See routine RemoveWhiteRects.)
  97.     Boolean            haveFileInfo;    //            file chosen?
  98.     FSSpec            fileInfo;        //            info about the file chosen.
  99. } BackwashCollection;
  100.  
  101.  
  102. // This structure is used by the ShapeToHandle and HandleToShape routines.
  103.         
  104. typedef struct UserSpool
  105. {
  106.     gxSpoolBlock    spool;        // struct passed to gxFlattenShape & gxUnflattenShape.
  107.     long            position;    // byte offset in handle for next read or write.
  108.     long            size;        // handle size.
  109.     void            *data;        // the handle we're working with.
  110. } UserSpool;
  111.  
  112.  
  113. #define kAllocationIncrement    (40L *1024L)    /* Initial handle size for flattened shape.    */ 
  114.  
  115.  
  116. // Function prototypes:
  117.  
  118. extern    long    A5Size (void);        /* We need these to set up        */
  119. extern    void    A5Init (void *);    /* our A5 world.                */
  120.  
  121. OSErr            BWInitialize(void);
  122. OSErr            BWShutDown(void);
  123. OSErr            BWJobPrintDialog(gxDialogResult *dlogResult);
  124. OSErr            BWHandlePanelEvent(gxPanelInfoRecord *panelInfo);
  125. OSErr            BWCreateSpoolFile(FSSpecPtr anFSSpec, long createOptions,
  126.                                   gxSpoolFile *theSpoolFile);
  127. OSErr            BWCloseSpoolFile(gxSpoolFile theSpoolFile, long closeOptions);
  128. OSErr            BWDespoolPage(gxSpoolFile theSpoolFile, long thePageNum,
  129.                               gxFormat theFormat, gxShape *thePage,
  130.                               Boolean *formatChanged);
  131. OSErr            InitGlobalData(void);
  132. OSErr            SetUpPrintPanel(void);
  133. void            OpenBackwashPanel(DialogPtr pDlg, short itemCount);
  134. PicHandle        LoadAPict(FSSpecPtr opFSSpec);
  135. gxGraphicsError    AddBackwash(FSSpecPtr fileInfo, short theIntensity,
  136.                             gxSpoolFile theSpoolFile);
  137. gxGraphicsError    SetShapeIntensity(gxShape theShape, short theIntensity);
  138. Boolean            RemoveWhiteRects(gxShape theShape);
  139. OSErr            GetJobCollectionItem(void *collectItem, long *collectSize,
  140.                                         OSType collectType, short collectID);
  141. gxGraphicsError    HandleSpoolProc(gxSpoolCommand command, UserSpool *block);
  142. Handle            ShapeToHandle(gxShape source);
  143. gxShape            HandleToShape(Handle source, long count, const gxViewPort portList[]);
  144. void            PositionWindow(WindowPtr windPtr, Boolean showIt, float vertPercent);
  145.